/**
 * 
 */
package com.ydy.configuration;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.github.wxpay.sdk.WXPayConfig;

/**
 * @author xuzhaojie
 *
 *         2019年6月3日 下午4:57:45
 */
@Component
public class WeChatConfig implements WXPayConfig {
	@Value("${wechat_appId:wxac2e97087946bf97}")
	private String appId;
	@Value("${wechat_appSecret:dbcb9d51af648df33ad745aab30cfc45}")
	private String appSecret;
	@Value("${mchId}")
	private String mchId;
	@Value("${wxpayKey}")
	private String wxpayKey;
	@Value("${wechat_redirect_url:http://maxkiddie.eicp.net/login.html}")
	private String redirectUri;
	@Value("${wechat_pay_notify_url}")
	private String wechatPayNotifyUrl;
	@Value("${wechat_refund_notify_url}")
	private String wechatRefundPayNotifyUrl;
	@Value("${p12_path}")
	private String p12Path;

	private String tradeType = "JSAPI";

	@Override
	public InputStream getCertStream() {
		File file = new File(p12Path);
		FileInputStream inputStream = null;
		try {
			inputStream = new FileInputStream(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return inputStream;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getAppSecret() {
		return appSecret;
	}

	public void setAppSecret(String appSecret) {
		this.appSecret = appSecret;
	}

	public String getMchId() {
		return mchId;
	}

	public void setMchId(String mchId) {
		this.mchId = mchId;
	}

	public String getWxpayKey() {
		return wxpayKey;
	}

	public void setWxpayKey(String wxpayKey) {
		this.wxpayKey = wxpayKey;
	}

	public String getRedirectUri() {
		return redirectUri;
	}

	public void setRedirectUri(String redirectUri) {
		this.redirectUri = redirectUri;
	}

	@Override
	public String getAppID() {
		// TODO Auto-generated method stub
		return this.appId;
	}

	@Override
	public String getMchID() {
		// TODO Auto-generated method stub
		return this.mchId;
	}

	@Override
	public String getKey() {
		// TODO Auto-generated method stub
		return this.wxpayKey;
	}

	@Override
	public int getHttpConnectTimeoutMs() {
		return 8000;
	}

	@Override
	public int getHttpReadTimeoutMs() {
		return 10000;
	}

	public String getWechatPayNotifyUrl() {
		return wechatPayNotifyUrl;
	}

	public void setWechatPayNotifyUrl(String wechatPayNotifyUrl) {
		this.wechatPayNotifyUrl = wechatPayNotifyUrl;
	}

	public String getTradeType() {
		return tradeType;
	}

	public void setTradeType(String tradeType) {
		this.tradeType = tradeType;
	}

	public String getWechatRefundPayNotifyUrl() {
		return wechatRefundPayNotifyUrl;
	}

	public void setWechatRefundPayNotifyUrl(String wechatRefundPayNotifyUrl) {
		this.wechatRefundPayNotifyUrl = wechatRefundPayNotifyUrl;
	}

}
